package org.example.practice.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.commonapi.domain.PracticeHistory;

import org.example.commonapi.dto.LoginInfo;
import org.example.commonapi.dto.PageInfo;
import org.example.commonapi.dto.PracticeHistoryDto;
import org.example.commonapi.mapper.PracticeHistoryMapper;
import org.example.commonapi.mapper.PracticeMapper;
import org.example.commonapi.util.JwtUtil;
import org.example.practice.service.PracticeHistoryService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author DELL
* @description 针对表【practice_history(学生刷题的历史记录)】的数据库操作Service实现
* @createDate 2024-06-12 18:14:02
*/
@Service
public class PracticeHistoryServiceImpl extends ServiceImpl<PracticeHistoryMapper, PracticeHistory>
    implements PracticeHistoryService {

    @Autowired
    private JwtUtil jwtUtil;

    @Resource
    private PracticeHistoryMapper practiceHistoryMapper;

    @Resource
    private PracticeMapper practiceMapper;

    /**
     * 查询学生刷题的历史记录
     * @param pageNum
     * @param pageSize
     * @param loginInfo
     * @return
     */
    @Override
    public PageInfo listHistory(Integer pageNum,Integer pageSize,LoginInfo loginInfo,String name) {
        Page<PracticeHistoryDto> page = new Page<>(pageNum,pageSize);
        IPage<PracticeHistoryDto> list=practiceHistoryMapper.listHistory(page,loginInfo.getId(),name);
        return new PageInfo(list);
    }
}




